//引入mysql
const mysql = require('mysql')
//创建链接对象
const con = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '123456',
    port: '3306',
    database: 'myblog'

})
//开始链接
con.connect()
//执行sql语句
const sql = 'select * from users;'
con.query(sql, (err, res) => {
    if (err) {
        console.log(err);
        return
    }
    console.log(res);
})

//关闭链接
con.end()
